package com.atguigu.controller;

import com.atguigu.service.OrderNacosService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @Description
 * @Author dubao
 * @Date 2023年 06月 07日 16:49
 **/
@RestController
public class OrderNacosController {
    @Resource
    private RestTemplate restTemplate;

    @Resource
    private OrderNacosService orderNacosService;

    @Value("${service-url.nacos-user-service}")
    private String serverURL;

    @GetMapping("/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Long id) {
        return restTemplate.getForObject(serverURL + "/payment/nacos/" + id, String.class);
    }

    @GetMapping(value = "/consumer/feign/payment/nacos/{id}")
    public String getPayment(@PathVariable("id") Integer id) {
         return orderNacosService.getPayment(id);
    }

}